#include "kernel.h"
#include "it.h"

titp g_it_p;

void it_set(titr *ir, uint32_t index, uint32_t offset, uint16_t selector, uint16_t attr){
	ir[index].offset_high = offset >> 16;
	ir[index].attr = attr | 0x0e00;
	ir[index].selector = selector;
	ir[index].offset_low = offset & 0xFFFF;
	//0xe00
	return;
}

titr* it_clear(unsigned int address, unsigned int count){
	//unsigned int *ptr = (unsigned int*)(address);
	unsigned int x;
	for(x = 0; x < count; ++x){
		// FIXME: figure out what is better, zeros or default selector with not present bit.
		//ptr[x*2+0] = 0;
		//ptr[x*2+1] = 0;
		it_set((titr*)address, x, 0x0, 0x8, 0x0);
	}
	g_it_p.limit = count * 8 - 1;
	g_it_p.address = address;
	return (titr*)(address);
}

